package com.zufe.Test2;

public class Test {
    public static void main(String[] args) {
        Phone phone = new OldPhone();
        testPhone(phone);
        phone = new NewPhone();
        testPhone(phone);
    }
    public static void testPhone(Phone phone) {
        if(phone instanceof OldPhone oldPhone){
            oldPhone.call();
            oldPhone.sendMessage();
        }else if(phone instanceof NewPhone newPhone){
            newPhone.call();
            newPhone.sendMessage();
            newPhone.playGame();
        }
    }
}
